package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConComplaint;
import com.htgd.gardenexpo.dao.GeConComplaintDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.page.ComplaintQuery;
import com.htgd.gardenexpo.service.CommonService;
import com.htgd.gardenexpo.service.GeConComplaintService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 投诉建议表(GeConComplaint)表服务实现类
 *
 * @author makejava
 * @since 2021-05-31 13:51:40
 */
@Service("geConComplaintService")
public class GeConComplaintServiceImpl implements GeConComplaintService {
    @Resource
    private GeConComplaintDao geConComplaintDao;

    @Override
    public List<GeConComplaint> list(ComplaintQuery pageQuery){
       return geConComplaintDao.list(pageQuery);
    }

    @Override
    public Long count(ComplaintQuery pageQuery){
        return geConComplaintDao.count(pageQuery);
    }
    /**
     * 通过ID查询单条数据
     *
     * @param complaintId 主键
     * @return 实例对象
     */
    @Override
    public GeConComplaint queryById(Integer complaintId) {
        return this.geConComplaintDao.queryById(complaintId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConComplaint> queryAllByLimit(int offset, int limit) {
        return this.geConComplaintDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<GeConComplaint> getAllComplaintByValue(PageQuery pageQuery) {
        return this.geConComplaintDao.getAllComplaintByValue(pageQuery);
    }

    /**
     * 新增数据
     *
     * @param geConComplaint 实例对象
     * @return 实例对象
     */
    @Override
    public GeConComplaint insert(GeConComplaint geConComplaint) {
        this.geConComplaintDao.insert(geConComplaint);
        return geConComplaint;
    }

    /**
     * 修改数据
     *
     * @param geConComplaint 实例对象
     * @return 实例对象
     */
    @Override
    public GeConComplaint update(GeConComplaint geConComplaint) {
        this.geConComplaintDao.update(geConComplaint);
        return this.queryById(geConComplaint.getComplaintId());
    }

    /**
     * 通过主键删除数据
     *
     * @param complaintId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer complaintId) {
        return this.geConComplaintDao.deleteById(complaintId) > 0;
    }
}
